
function renderProduct(arr) {
let html = '';
arr.forEach(item => {
    
    html += `<div id="goods">
    <a href="moneytiao.html?productid=${item.productId}">
    ${item.productImg2}
    <div class="info">
    <h4>${item.productName}</h4>
    <span>${item.productFrom}| ${item.productTime}</span>
    <i>✉${item.productComCount}</i>
    </div>
    </a>
    `
})

return html;

}

        let btns = document.querySelectorAll('#btn button')
        let pageid = 0
        btns.forEach(btns => {
            btns.onclick = function() {
            if(this.innerText === '下一页') {
                // console.log(9999);
                pageid++;
                back(pageid)
            }else if (this.innerText === '上一页') {
                pageid--;
                back(pageid)
            }
            }
        })

        function back(pageid) {
            $.ajax({
                url:'http://chst.vip:1234/api/getmoneyctrl?pageid=' + pageid ,
            }).then(res => {
                console.log(res.result);
                let html = ''
                res.result.forEach(item => {
                    html = `
                    <div id="goods">
                <a href="moneytiao.html?productid=${item.productId}">
                ${item.productImg2}
                <div class="info">
                <h4>${item.productName}</h4>
                <span>${item.productFrom}| ${item.productTime}</span>
                <i>✉${item.productComCount}</i>
                </div>
                </a>
                    `
                })

                let body = document.getElementById("body");

                body.innerHTML = renderProduct(res.result)

            })
            
        }
        back(0)



let goTop = document.getElementById('goTop');
goTop.onclick = function() {
document.documentElement.scrollTop = 0
}